/*
 * copyright (c) 2009 Alexandr [Sn@ble] Surnin
 *
 * This file is part of FrameSeeker.
 *
 * FrameSeeker is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * FrameSeeker is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *fre
 * You can read the full version of GNU LGPL in
 * http://www.gnu.org/copyleft/lesser.html
 */


#include "FSCoreMethod.h"


int FSCoreMethod::testingMode;


FSCoreMethod::FSCoreMethod() {

    prev = new FSFrame();
    current = new FSFrame();
    next = new FSFrame();

    needNext = 0;


}

FSCoreMethod::~FSCoreMethod() {

    delete prev;
    delete current;
    delete next;
}

void FSCoreMethod::setFrame(FSFrame *frame) {

    if (needNext) {
        next->copy(frame); // Third is "next"
        needNext = 0;
//        qDebug() << "before process() current index:" << current->index();
        if (prev && (prev->index() < 100000000) && (prev->index() > 0)) process();
        return;
    }

    if ((frame->type() != FS_FRAME_TYPE_I) | (prev->_width() == 0)) {
        prev->copy(frame); // First frame is "previous"
    } else {
        current->copy(frame);
        needNext = 1; // Second is "current"
    }

}

void FSCoreMethod::process() {

    qDebug() << "OVERRIDE FSCoreMethod::process() in your method class !!!!!!!!";
}


void FSCoreMethod::readSettings(QSettings *settings) {


    qDebug() << "OVERRIDE FSCoreMethod::readSettings() in your method class !!!!!!!!!";
}


void FSCoreMethod::setTestingMode(bool tm) {

    testingMode = tm ? 1 : 0;
}
